import Mock from 'mockjs'
import books from './book.json'
Mock.mock('/mock/books', 'get', {
  code: 200,
  message: 'success',
  data: books,
})
Mock.mock('/mock/addBook', 'post', (options) => {
  const book = {
    id: books.length + 1,
    title: '新书' + (books.length + 1),
    author: '作者' + (books.length + 1),
    price: (Math.random() * 100).toFixed(2),
  }
  return {
    code: 200,
    message: '添加成功',
    data: book,
  }
})
